home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CLOBSH.PAK / SORTABLE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  112 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  SORTABLE.H                                                            */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1993                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( _SORTABLE_H )
  11. #define _SORTABLE_H
  12.  
  13. #define BI_OLDNAMES
  14.  
  15. #if !defined( __CLSDEFS_H )
  16. #include "classlib\obsolete\ClsDefs.h"
  17. #endif  // __CLSDEFS_H
  18.  
  19. #if !defined( __OBJECT_H )
  20. #include "classlib\obsolete\Object.h"
  21. #endif  // __OBJECT_H
  22.  
  23. #if !defined( __CHECKS_H )
  24. #include <checks.h>
  25. #endif  // __CHECKS_H
  26.  
  27. #pragma option -Vo-
  28. #if defined( __BCOPT__ ) && !defined( __FLAT__ ) && !defined( _ALLOW_po )
  29. #pragma option -po-
  30. #endif
  31.  
  32. _CLASSDEF(ostream)
  33. _CLASSDEF(Sortable)
  34.  
  35. class _CLASSTYPE Sortable : public Object
  36. {
  37.  
  38. public:
  39.  
  40.     virtual int isEqual( const Object _FAR & ) const = 0;
  41.     virtual int isLessThan( const Object _FAR & ) const = 0;
  42.     virtual int isSortable() const
  43.         {
  44.         return 1;
  45.         }
  46.  
  47.     virtual classType isA() const = 0;
  48.     virtual _TCHAR _FAR *nameOf() const = 0;
  49.     virtual hashValueType hashValue() const = 0;
  50.     virtual void printOn( ostream& ) const = 0;
  51.  
  52. };
  53.  
  54. inline
  55. int operator < ( const Object _FAR & test1, const Object _FAR & test2 )
  56. {
  57.     CHECK( test1.isSortable() && test2.isSortable() );
  58.     return ((Sortable&)test1) < ((Sortable&)test2);
  59. }
  60.  
  61. inline
  62. int operator > ( const Object _FAR & test1, const Object _FAR & test2 )
  63. {
  64.     CHECK( test1.isSortable() && test2.isSortable() );
  65.     return ((Sortable&)test1) > ((Sortable&)test2);
  66. }
  67.  
  68. inline
  69. int operator >= ( const Object _FAR & test1, const Object _FAR & test2 )
  70. {
  71.     CHECK( test1.isSortable() && test2.isSortable() );
  72.     return ((Sortable&)test1) >= ((Sortable&)test2);
  73. }
  74.  
  75. inline
  76. int operator <= ( const Object _FAR & test1, const Object _FAR & test2 )
  77. {
  78.     CHECK( test1.isSortable() && test2.isSortable() );
  79.     return ((Sortable&)test1) <= ((Sortable&)test2);
  80. }
  81.  
  82. inline
  83. int operator < ( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  84. {
  85.     return ( (test1.isA() == test2.isA()) && test1.isLessThan( test2 ) );
  86. }
  87.  
  88. inline
  89. int operator > ( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  90. {
  91.     return !( test1 < test2 ) && test1 != test2;
  92. }
  93.  
  94. inline
  95. int operator >=( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  96. {
  97.     return ( !( test1 <( test2 ) ) );
  98. }
  99.  
  100. inline
  101. int operator <=( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  102. {
  103.     return ( test1 < test2 || test1 == test2 );
  104. }
  105.  
  106. #if defined( __BCOPT__ ) && !defined( __FLAT__ ) && !defined( _ALLOW_po )
  107. #pragma option -po.
  108. #endif
  109. #pragma option -Vo.
  110.  
  111. #endif
  112.